function elementCounter(element, array)
{
    var elementCount = 0;

    for (var i = 0; i < array.length; i++)
    {
        if (array[i] === element)
        {
            elementCount++;
        }
    }

    return elementCount;
}

console.log(elementCounter(5, [1, 2, 3, 4, 5, 6, 3, 5, 3, 5]));

function testElementCounter(element, array, expectedResult)
{
    var elementCounterResult = elementCounter(element, array);

    if (elementCounterResult === expectedResult)
    {
        console.log("Everything is fine");
    }
    else
    {
        console.log("Unexpected issue");
    }
}

testElementCounter(5, [1, 2, 3, 4, 5, 6, 3, 5, 3, 5], 3);
testElementCounter(5, [1, 2, 3, 4, 5, 6, 3, 5, 3, 5], 4);